package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ActivityCollect;
import com.ruoyi.system.service.IActivityCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 会议收集Controller
 *
 * @author ruoyi
 * @date 2024-04-04
 */
@RestController
@RequestMapping("/system/activity/collect")
public class ActivityCollectController extends BaseController
{
    @Autowired
    private IActivityCollectService activityCollectService;

    /**
     * 查询会议收集列表
     */
    @PreAuthorize("@ss.hasPermi('system:collect:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody ActivityCollect activityCollect)
    {
        setStartPage(activityCollect.getPageNum(),activityCollect.getPageSize());
        List<ActivityCollect> list = activityCollectService.selectActivityCollectList(activityCollect);
        return getDataTable(list);
    }


    /**
     * 获取会议收集详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:collect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(activityCollectService.selectActivityCollectById(id));
    }

    /**
     * 新增会议收集
     */
    @PreAuthorize("@ss.hasPermi('system:collect:add')")
    @Log(title = "会议收集", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ActivityCollect activityCollect)
    {
        return toAjax(activityCollectService.insertActivityCollect(activityCollect));
    }

    /**
     * 修改会议收集
     */
    @PreAuthorize("@ss.hasPermi('system:collect:edit')")
    @Log(title = "会议收集", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ActivityCollect activityCollect)
    {
        return toAjax(activityCollectService.updateActivityCollect(activityCollect));
    }

    /**
     * 删除会议收集
     */
    @PreAuthorize("@ss.hasPermi('system:collect:remove')")
    @Log(title = "会议收集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(activityCollectService.deleteActivityCollectById(id));
    }
}
